﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;

namespace QQ.Util
{
   public static class Tools
    {
        public static long GetTime(DateTime dateTime)
        {
            DateTime startDate = new DateTime(1970, 1, 1);
            DateTime endDate = dateTime.ToUniversalTime();
            TimeSpan span = endDate - startDate;
            return (long)(span.TotalMilliseconds + 0.5);
        }

        public static long GetNowTime()
        {
            return GetTime(new DateTime());
        }

       /// <summary>
       /// 正则封装
       /// </summary>
       /// <param name="pattern"></param>
       /// <param name="content"></param>
       /// <param name="name"></param>
       /// <returns></returns>
        public static string myPattern(string pattern, string content, string name)
        {
            Match match = Regex.Match(content, pattern);
            string result = "";
            if (match.Success)
            {
                GroupCollection groups = match.Groups;
                result = groups[name].ToString();   

            }
            else
            {
                result = "";
            }

            return result;

        }


     

    }
}
